package org.example.cloudalibaba.myhandler;

import cn.hutool.core.util.IdUtil;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.example.springcloud.common.Result;


public class MyFallbackHandler {
    // 资源有的参数，兜底方法也必须有
    public static Result<String> defaultFallback() {
        return Result.success("请求降级了, uuid = {}", IdUtil.fastSimpleUUID());
    }
// 注意参数顺序，blockHandler：Long id, BlockException e，fallback：Long id, Throwable e，都是参数在前，异常类在后
    public static Result<String> paymentInfoFallback(Long id, Throwable e) {
        String message = e.getMessage();
        return Result.success("请求降级了,id = {}, message = {}, uuid = {}", id, message, IdUtil.fastSimpleUUID());
    }
}
